package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dao.GoodsDao;
import com.pojo.Goods;
import com.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lifeng
 * @create 2022-11-18 11:50
 */
@Service
public class GoodsServiceImpl implements GoodsService {

    //注入dao层
    @Autowired
    private GoodsDao goodsDao;

    //主要用于复杂查询
//    QueryWrapper queryWrapper = new QueryWrapper();

    @Override
    public List<Goods> findAll() {
        return goodsDao.selectList(null);
    }

    @Override
    public boolean insertGoods() {
        Goods goods = new Goods();
        goods.setGoodsName("拖鞋");
        goods.setGoodsDetail("这是一双好拖鞋");
        goods.setGoodsPrice(5300);
        goods.setGoodsGrade(4);
        goods.setGoodsInventory(400);
        goods.setIsHot('是');
        goods.setMerchantId(1);
        goods.setBuyNum(13);
        goods.setE_id(3);
        return goodsDao.insert(goods) > 0 ? true : false;
    }

    @Override
    public Goods findById(Integer id) {
        return goodsDao.selectById(id);
    }
}
